<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <!--    <link href="/static/css/dialog.css" rel="stylesheet"/>-->
    <!--    <script src="/static/js/dialog.js"></script>-->
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>



    <!--开关主键-->
    <script src="/static/bootstrap/bootstrap-switch.js"></script>
    <link href="/static/bootstrap/bootstrap-switch.css" rel="stylesheet"/>

    <!-- PNotify -->
    <script type="text/javascript" src="/static/pnotify/pnotify.js"></script>
    <link href="/static/pnotify/pnotify.css" rel="stylesheet" type="text/css"/>
    <link href="/static/pnotify/pnotify.brighttheme.css" rel="stylesheet" type="text/css"/>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}
</head>
<body>

<!--<div class="modal-header">-->
<!--&lt;!&ndash;    <button type="button" class="close" data-dismiss="modal" close="true">&ndash;&gt;-->
<!--&lt;!&ndash;        <span aria-hidden="true">×</span>&ndash;&gt;-->
<!--&lt;!&ndash;    </button>&ndash;&gt;-->
<!--    <h4 class="modal-title">-->
<!--        <span class="fa fa-legal"></span>&nbsp;微信配置-->
<!--    </h4>-->
<!--</div>-->
<style>
    .modal-body{background-color:#fff!important;}
    .form-horizontal .control-label{display: inline-block;width:10%;
        text-align:justify!important;
        text-align-last:justify;/*解决IE的支持*/ }
</style>

<div class="config_content newtest">
    <div class="modal-body">
        <form class="form-horizontal layui-form">
            <div class="form-group">
                <label class="col-sm-2 control-label">公众号名称</label>
                <div class="col-sm-4">
                    <input class="form-control" name="name" placeholder="公众号名称" value="{$config.name}">
                    <p class="pic">填写公众号的账号名称</p>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label">描述</label>
                <div class="col-sm-4">
                    <textarea class="form-control ng-binding" name="desc">{$config.desc}</textarea>
                    <p class="pic">用于说明此公众号的功能及用途。</p>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label"> 公众号账号</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="account" value="{$config.account}" >
                    <p class="pic">填写公众号的账号,一般为英文账号。</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> 原始ID</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="primeval" value="{$config.primeval}"  >
                    <p class="pic">原始ID不能修改,请谨慎填写。</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> 类型</label>
                <div class="col-sm-8">

                    <select name="type" lay-filter="aihao">
                        <option value=""></option>
                        {volist name="accounts" id="vo"}
                        <option value="{$key}" {if condition="$config.type eq $key"} selected {/if} >{$vo}</option>
                        {/volist}
                    </select>


                    <p class="pic">注意:即使公众平台显示为“未认证”, 但只要【公众号设置】/【账号详情】下【认证情况】显示资质审核通过, 即可认定为认证号.</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> AppId</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="appid" value="{$config.appid}" >
                    <p class="pic">请填写微信公众平台后台的AppId</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> AppSecret</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="appsecret" value="{$config.appsecret}" >
                    <p class="pic">请填写微信公众平台后台的AppSecret</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> EncodingAESKey</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="EncodingAESKey" value="{$config.EncodingAESKey}" >
                    <p class="pic">微信公众号EncodingAESKey</p>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label"> 小程序AppId</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="xcx_appid" value="{$config.xcx_appid}" >
                    <p class="pic">请填写微信公众平台后台的AppId</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"> 小程序AppSecret</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="xcx_appsecret" value="{$config.xcx_appsecret}" >
                    <p class="pic">请填写微信小程序后台的AppSecret</p>
                </div>
            </div>

<!--            <div class="form-group">-->
<!--                <label class="col-sm-2 control-label"> 微信公众号商户号:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input type="text" class="form-control" name="wechat_mch_id" value="{$config.wechat_mch_id}" >-->
<!--                    <p class="pic">微信公众号商户号</p>-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-2 control-label"> 微信公众号商户支付密钥:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input type="text" class="form-control" name="wechat_key" value="{$config.wechat_key}" >-->
<!--                    <p class="pic">微信公众号商户支付密钥</p>-->
<!--                </div>-->
<!--            </div>-->




            <div class="form-group">
                <label class="col-sm-2 control-label"> token</label>
                <div class="col-sm-4">
                    <input type="text" disabled class="form-control" name="token" value="{$config.token}"  >
                    <input type="hidden" class="form-control" name="token" value="{$config.token}"  >
                    <p class="pic">请设置token</p>
                </div>
                <a class="btn btn-primary col-sm-1 create_token">生成token</a>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label"> Oauth 2.0</label>
                <div class="col-sm-8">
                    在微信公众号请求用户网页授权之前，开发者需要先到公众平台网站的【开发者中心】网页服务中配置授权回调域名。
                </div>
            </div>

            <div class="form-group js_photos">
                <label class="col-sm-2 control-label"> 头像</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="file" name="" class="do_upload" data-val="idCard_handheld"  style="display: none">
                        <input type="text" class="form-control idCard_handheld"  disabled="" value="{$config.avatar}">
                        <input type="hidden" class="form-control idCard_handheld" name="avatar" value="{$config.avatar}" >
                        <span class="group-span-filestyle input-group-btn" tabindex="0">
                            <label class="btn btn-default id_photos" data-original-title="" title="">
                                <span class="glyphicon glyphicon-folder-open"></span>
                                上传
                            </label>
                        </span>
                    </span>
                    </div>
                    <img class="config_img idCard_handheld" src="{$config.avatar}" >
                </div>
            </div>

            <div class="form-group js_photos">
                <label class="col-sm-2 control-label"> 二维码</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="file" name="" class="do_upload" data-val="idCard_positive"  style="display: none">
                        <input type="text" class="form-control idCard_positive" name="idCard_positive" disabled="" value="{$config.qr_code}" >
                        <input type="hidden" class="form-control idCard_positive" name="qr_code" value="{$config.qr_code}" >
                        <span class="group-span-filestyle input-group-btn" tabindex="0">
                            <label class="btn btn-default id_photos" data-original-title="" title="">
                                <span class="glyphicon glyphicon-folder-open"></span>
                                上传
                            </label>
                        </span>
                    </span>
                    </div>
                    <img class="config_img idCard_positive" src="{$config.qr_code}" >
                </div>
            </div>


            <div class="form-group js_photos">
                <label class="col-sm-2 control-label"> 小程序二维码</label>
                <div class="col-sm-4">
                    <div class="input-group ">
                        <input type="file" name="" class="do_upload" data-val="xcx_code"  style="display: none">
                        <input type="text" class="form-control xcx_code" name="xcx_code" disabled="" value="{$config.xcx_code}" >
                        <input type="hidden" class="form-control xcx_code" name="xcx_code" value="{$config.xcx_code}" >
                        <span class="group-span-filestyle input-group-btn" tabindex="0">
                            <label class="btn btn-default id_photos" data-original-title="" title="">
                                <span class="glyphicon glyphicon-folder-open"></span>
                                上传
                            </label>
                        </span>
                        </span>
                    </div>
                    <img class="config_img xcx_code" src="{$config.xcx_code}" >
                </div>
            </div>

            <input name="id" type="hidden" value="{$config.id}">
        </form>
    </div>
    <div class="modal-footer">
        <a type="button" class="layui-btn layui-btn-primary" href="{:Url('admin/System/index')}" >返回列表</a>
        <button type="button" class="layui-btn js_btn" >保存</button>
    </div>
</div>


<script>
    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");
        var index = layer.msg('正在提交中....');

        $.ajax({
            url: "{:URL('common/upload/ad_upload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                $("."+content).find("img").attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })


    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;


        //生成token
        $(".create_token").click(function () {
            $.ajax({
                type: "post",
                url: "{:URL('admin/system/createtoken')}",
                dataType: "json",
                success: function(data){
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        $('input[name="token"]').val(data.token);
                    }

                }
            });
        });

        $(".js_btn").click(function () {
           var data = $("form").serialize();
            $.ajax({
                type: "post",
                url: "{:URL('admin/system/config')}",
                data: data,
                dataType: "json",
                success: function(data){
                    layer.alert(data.msg);
                    if(data.code==0){
                        window.location.href = "{:URL('admin/system/index')}";
                        //window.location.reload();
                    }
                }
            });
           console.log(data);
        });

    });


    $(this).find('.modal-dialog').css({
        'width': '800px'
    });

</script>
</body>
</html>
